package com.blue.wechat.invoke.spi.media;

import com.alibaba.fastjson.JSONObject;
import com.blue.core.dict.HttpMethod;
import com.blue.wechat.cache.Wechat;
import com.blue.wechat.invoke.BaseInvoker;
import com.blue.wechat.invoke.WechatInvokeUtil;
import com.blue.wechat.invoke.WechatInvoker;
import com.blue.wechat.invoke.annotation.WechatUrl;
import com.blue.wechat.invoke.model.ErrorMsg;

/**
 * 删除永久素材
 * 
 * @author zhengj
 * @since 1.0 2017年6月12日
 */
@WechatUrl(WechatInvoker.DELETE_MATERIAL)
public class DeleteMaterialInvoker extends BaseInvoker<ErrorMsg>
{
	public DeleteMaterialInvoker()
	{
	}

	@Override
	protected WechatInvoker getInvoker()
	{
		return WechatInvoker.DELETE_MATERIAL;
	}
	
	@Override
	protected String invoke(String url, HttpMethod method, Object post) throws Exception
	{
		JSONObject json = new JSONObject();
		json.put("media_id", post);
		
		String resp = httpInvoker.post(url, json.toJSONString());
		return resp;
	}

	@Override
	protected ErrorMsg handleSuccess(String resp, Wechat wechat)
	{
		ErrorMsg msg = WechatInvokeUtil.toResponse(resp, ErrorMsg.class);
		return msg;
	}
	
	
}
